package edu.gatech.cs2340.group7.wheresmystuffapp.views;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import edu.gatech.cs2340.group7.wheresmystuffapp.R;
import edu.gatech.cs2340.group7.wheresmystuffapp.presenters.ForgotAccountPresenter;

public class ForgotAccountView extends Activity implements View.OnClickListener {
	private ForgotAccountPresenter myPresenter;
	private Button bSendEmail;
	private EditText etEmailAddress;
	private TextView confirmation;

	@Override
	public void onClick(View v) {
		try {
			String emailAddress = etEmailAddress.getText().toString();
			myPresenter.sendEmail(emailAddress);
		} catch (Exception fail) {
			confirmation.setText("Invalid Information");
			confirmation.setTextColor(Color.RED);
		}

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_display_forgot_account);

		linkSetup();
		myPresenter = new ForgotAccountPresenter(this);
	}

	/**
	 * Initializes all of the views in the XML layout file, and sets the listener for the button
	 */
	private void linkSetup() {
		bSendEmail = (Button) findViewById(R.id.bSendEmail);
		bSendEmail.setOnClickListener(this);
		etEmailAddress = (EditText) findViewById(R.id.etEmail);
		confirmation = (TextView) findViewById(R.id.tvCreateAccountResult);
		// subject = "Where's My Stuff Forgot Password";

	}
}
